package com.itheima.test;

import com.itheima.w_util.FreemarkerUtil;

import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class FreemarkerDemo {
    public static void main(String[] args) {
        Map<String, Object> dataModel = new HashMap<>();
        dataModel.put("groupId", "com.example");
        dataModel.put("artifactId", "demo-project");
        dataModel.put("version", "1.0.0");
        dataModel.put("name", "Demo Project");
        dataModel.put("description", "jjjjj");


        Map<String, String> properties = new HashMap<>();
        properties.put("project.build.sourceEncoding", "UTF-8");
        properties.put("java.version", "11");
        dataModel.put("properties", properties);
        List<Map<String, String>> dependencies = new ArrayList<>();
        
        Map<String, String> dep1 = new HashMap<>();
        dep1.put("groupId", "org.springframework.boot");
        dep1.put("artifactId", "spring-boot-starter-web");
        dep1.put("version", "2.5.4");
        dependencies.add(dep1);
        
        Map<String, String> dep2 = new HashMap<>();
        dep2.put("groupId", "org.projectlombok");
        dep2.put("artifactId", "lombok");
        dep2.put("version", "1.18.20");
        dep2.put("scope", "provided");
        dependencies.add(dep2);
        
        dataModel.put("dependencies", dependencies);

        List<String> modules = new ArrayList<>();
        modules.add("module1");
        modules.add("module2");
        modules.add("module3");
        FreemarkerUtil.renderToFile("pom.ftl", dataModel, new File("./generate_pom.xml"));
        System.out.println("渲染完成");
    }
}